package com.xk857.system.mapper.provider;



import com.baomidou.mybatisplus.core.toolkit.IdWorker;

import java.util.List;

/**
 * @author CV大魔王
 * @Description 角色相关动态SQL
 * @date 2021/2/25 21:40
 */
public class SysRoleProvider {

    public String saveRoleMenu(String roleId, List<String> menuIds){
        StringBuilder sql = new StringBuilder();
        sql.append("INSERT INTO sys_role_menu(id, role_id, menu_id) VALUES ");
        for (int i = 0; i < menuIds.size(); i++) {
            if (i == menuIds.size() - 1) {
                sql.append(" (").append(IdWorker.getId()).append(", ").append(roleId).append(" , ").append(menuIds.get(i)).append(") ");
            }else {
                sql.append(" (").append(IdWorker.getId()).append(", ").append(roleId).append(" , ").append(menuIds.get(i)).append("), ");
            }
        }
        return sql.toString();
    }

}
